<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>pvshift</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="pvsgain.html" title="pvsgain" />
    <link rel="next" href="pvsifd.html" title="pvsifd" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">pvshift</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="pvsgain.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="pvsifd.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="pvshift"></a>
      <div class="titlepage"></div>
      <a id="IndexPvshift" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">pvshift</span>
        </h2>
        <p>pvshift — 
      Shift the frequency components of a pv stream, stretching/compressing
      its spectrum.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp139044464"></a>
        <h2>Description</h2>
        <p>
      Shift the frequency components of a pv stream, stretching/compressing
      its spectrum.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp139045728"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">fsig <span class="command"><strong>pvshift</strong></span> fsigin, kshift, klowest[, kkeepform, igain, kcoefs]</pre>
      </div>
      <div class="refsect1">
        <a id="idp139047808"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>fsig</em></span> -- output pv stream
    </p>
        <p>
      <span class="emphasis"><em>fsigin</em></span> -- input pv stream
    </p>
        <p>
      <span class="emphasis"><em>kshift</em></span> -- shift amount (in Hz, positive or negative).
    </p>
        <p>
      <span class="emphasis"><em>klowest</em></span> -- lowest frequency to be shifted. 
    </p>
        <p>
      <span class="emphasis"><em>kkeepform</em></span> -- attempt to keep input signal
      formants; 0: do not keep formants;
      1: keep formants using a liftered cepstrum method; 2: keep formants by 
      using a true envelope method
      (defaults to 0). 
    </p>
        <p>
      <span class="emphasis"><em>kgain</em></span> -- amplitude scaling (defaults to 1).
    </p>
        <p>
      <span class="emphasis"><em>kcoefs</em></span> -- number of cepstrum coefs used in formant preservation (defaults to 80).
    </p>
        <p>
      This opcode will shift the components of a pv stream, from a certain
      frequency upwards, up or down a fixed amount (in Hz). It can be used to 
      transform a harmonic spectrum into an inharmonic one. The <span class="emphasis"><em>kkeepform</em></span> flag 
      can be used to try and preserve formants for possibly interesting and unusual
      spectral modifications.
    </p>
        <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Warning">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Warning]" src="images/warning.png" />
              </td>
              <th align="left">Warning</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        It is unsafe to use the same f-variable for both input and output of pvs opcodes. Using the same one might lead to undefined behavior on some opcodes. Use a different one on the left and right sides of the opcode.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp139056976"></a>
        <h2>Examples</h2>
        <p>
      </p>
        <div class="example">
          <a id="idp139057904"></a>
          <p class="title">
            <strong>Example 696. Example</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
asig  <span class="opc">in</span>                                 <span class="comment">; get the signal in</span>

fsig  <span class="opc">pvsanal</span>   asig, 1024, 256, 1024, 1 <span class="comment">; analyse it</span>
ftps  <span class="opc">pvshift</span>   fsig, 100, 0             <span class="comment">; add 100 Hz to each component</span>
atps  <span class="opc">pvsynth</span>   ftps                     <span class="comment">; synthesise it</span></pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      Depending on the input, this will transform a pitched sound into an inharmonic,
      bell-like sound.
    </p>
        <p>
      Here is an example of the use of the <span class="emphasis"><em>pvshift</em></span> opcode. It uses the file <a class="ulink" href="examples/pvshift.csd" target="_top"><em class="citetitle">pvshift.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp139067136"></a>
          <p class="title">
            <strong>Example 697. Example of the <span class="emphasis"><em>pvshift</em></span> opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
-odac
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 16
<span class="ohdr">nchnls</span> <span class="op">=</span> 1
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="comment">;; example written by joachim heintz 2009</span>

<span class="oblock">instr</span> 1
ishift		<span class="op">=</span>		p4<span class="comment">; shift amount in Hz</span>
ilowest	<span class="op">=</span>		p5<span class="comment">; lowest frequency to be shifted</span>
ikeepform	<span class="op">=</span>		p6<span class="comment">; 0=no formant keeping, 1=keep by amps, 2=keep by spectral envelope</span>
ifftsize	<span class="op">=</span>		1024
ioverlap	<span class="op">=</span>		ifftsize <span class="op">/</span> 4
iwinsize	<span class="op">=</span>		ifftsize
iwinshape	<span class="op">=</span>		1<span class="comment">; von-Hann window</span>
Sfile		<span class="op">=</span>		"fox.wav"
ain		<span class="opc">soundin</span>	Sfile
fftin		<span class="opc">pvsanal</span>	ain, ifftsize, ioverlap, iwinsize, iwinshape<span class="comment">; fft-analysis of file</span>
fshift		<span class="opc">pvshift</span>  	fftin, ishift, ilowest, ikeepform<span class="comment">; shift frequencies</span>
aout		<span class="opc">pvsynth</span>	fshift<span class="comment">; resynthesize</span>
		<span class="opc">out</span>		aout
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> 1 0 2.757 0 0 0<span class="comment">; no shift at all</span>
<span class="stamnt">i</span> 1 3 2.757 100 0 0<span class="comment">; shift all frequencies by 100 Hz</span>
<span class="stamnt">i</span> 1 6 2.757 200 0 0<span class="comment">; by 200 Hz</span>
<span class="stamnt">i</span> 1 9 2.757 200 0 1<span class="comment">; keep formants by method 1</span>
<span class="stamnt">i</span> 1 12 2.757 200 0 2<span class="comment">; by method 2</span>
<span class="stamnt">i</span> 1 15 2.757 200 1000 0<span class="comment">; shift by 200 Hz but just above 1000 Hz</span>
<span class="stamnt">i</span> 1 18 2.757 1000 500 0<span class="comment">; shift by 1000 Hz above 500 Hz</span>
<span class="stamnt">i</span> 1 21 2.757 1000 300 0<span class="comment">; above 300 Hz</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp139071856"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="pvsanal.html" title="pvsanal"><em class="citetitle">pvsanal</em></a>,
      <a class="link" href="pvsynth.html" title="pvsynth"><em class="citetitle">pvsynth</em></a>,
      <a class="link" href="pvsadsyn.html" title="pvsadsyn"><em class="citetitle">pvsadsyn</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp139075824"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Victor Lazzarini</td>
          </tr>
          <tr>
            <td>November 2004 </td>
          </tr>
        </table>
        <p>
    </p>
        <p>New plugin in version 5</p>
        <p>November 2004.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="pvsgain.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="pvsifd.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">pvsgain </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> pvsifd</td>
        </tr>
      </table>
    </div>
  </body>
</html>
